//
//  CJSplashCustomEvent.m
//  CJMobileAdapter
//
//  Created by ly on 2024/2/29.
//

#import "CJSplashCustomEvent.h"

@implementation CJSplashCustomEvent

- (NSString *)networkUnitId {
    return self.serverInfo[@"unitid"];
}

- (void)removeCustomViewAndsplashAd:(CJSplashAd *)splashAd {
    if (self.containerView) { [self.containerView removeFromSuperview]; }
    if (splashAd) { splashAd = nil; }
}

- (void)splashAdDidLoad:(nonnull CJSplashAd *)splashAd resourceId:(nonnull NSString *)resourceId {
    [self trackSplashAdLoaded:splashAd adExtra:nil];
    self.requestCompletionBlock(@[], nil);
}

- (void)splashAdLoadFailed:(nonnull CJSplashAd *)splashAd error:(nonnull NSError *)error {
    [self removeCustomViewAndsplashAd:splashAd];
    [self trackSplashAdLoadFailed:error];
}

- (void)splashAdOnClicked:(nonnull CJSplashAd *)splashAd {
    [self trackSplashAdClick];
}

- (void)splashAdOnClosed:(nonnull CJSplashAd *)splashAd {
    [self removeCustomViewAndsplashAd:splashAd];
    [self trackSplashAdClosed:nil];
}

- (void)splashAdOnShow:(nonnull CJSplashAd *)splashAd {
    [self trackSplashAdShow];
}

@end
